#include "CameraComponent.h"
#include "Scene.h"

#include "SceneSubsystems/SceneCameraSubsystem.h"

void RCameraComponent::OnBeginPlay()
{
    GetScene()->GetSubsystem<RSceneCameraManager>()
        ->RegisterComponent(this);
}

void RCameraComponent::OnEndPlay()
{
    GetScene()->GetSubsystem<RSceneCameraManager>()
        ->UnregisterComponent(this);
}

SRawCameraParameters RCameraComponent::GetViewportParameter()
{
    SRawCameraParameters Parameter;
    Parameter.AspectRatio=AspectRatio;
    Parameter.PerspectiveFOVY=PerspectiveFOVY;
    Parameter.ProjectionType=bUseOrthographicProjection?EProjectionType::Orthographic:EProjectionType::Perspective;
    Parameter.OrthographicWidth=OrthographicWidth;
    Parameter.Near=Near;
    Parameter.Far=Far;
    Parameter.ViewportPosition=GetNode()->GetWorldPosition();
    Parameter.ViewportRotation=GetNode()->GetWorldRotation();

    return Parameter;

}
